#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=200;
typedef long long LL;
LL a[maxn],b[maxn],sum1[maxn],sum2[maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
  memset(sum1,0,sizeof(sum1));memset(sum2,0,sizeof(sum2));
  memset(a,0,sizeof(a));memset(b,0,sizeof(b));
  LL n;cin>>n;
  for(LL i=1;i<=n;i++){
    cin>>a[i];sum1[i]=sum1[i-1]+a[i];
  }
  LL m;cin>>m;
  for(LL i=1;i<=m;i++){
    cin>>b[i];sum2[i]=sum2[i-1]+b[i];
  }
  LL mx1=-1e18;LL mx2=-1e18;
  for(LL i=1;i<=n;i++){
    mx1=max(mx1,sum1[i]);
  }
  for(LL i=1;i<=m;i++){
    mx2=max(mx2,sum2[i]);
  }
  cout<<max(mx1+mx2,max(max(mx1,mx2),(LL)0))<<endl;
  }
return 0;
}
